package com.xian.cloud.controller;

import com.xian.cloud.api.UserDubboApi;
import com.xian.cloud.entity.User;
import com.xian.cloud.entity.UserEntity;
import com.xian.cloud.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xlr
 * @Date: Created in 5:33 PM 2019/8/23
 */
@Slf4j
@RestController
@RequestMapping("server")
public class TestController {

    @Autowired
    private UserDubboApi userDubboApi;

    @Autowired
    private UserService userService;

    /**
     * loadBalancerClient
     * @return
     */
    @GetMapping("/test")
    public User test(@RequestParam("name")String name) {
        return userDubboApi.info( name );
    }


    @PostMapping("/update")
    public boolean update(@RequestParam("name")User user) {
        UserEntity userEntity = new UserEntity();
        BeanUtils.copyProperties(user,userEntity);
        boolean b = userService.updateById(userEntity);
        return b;
    }

}
